package com.ay272.sshupdate.web;


import com.ay272.sshupdate.entity.User;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap;

/*
 * Created by Administrator on 2016/5/23.
 */
@Controller
@RequestMapping("/home")
public class HomeController {
    @RequestMapping("/index")
    public String index(){
        System.out.println("mvc------------");
        return "home";
    }
    @RequestMapping(value="/save",method = RequestMethod.POST)
    public  String save(User user, RedirectAttributesModelMap model){
        System.out.println(user);
        model.addFlashAttribute("u",user);
        return "redirect:show.action";
    }
    @RequestMapping("/show")
    public String show(){
    return "show";
    }

    @RequestMapping("/ajaxSave")
    @ResponseBody
    public  User save(User user){
        System.out.println(user);

        return user;

    }

}
